﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.BLL;

public partial class admin_Login : System.Web.UI.Page
{
    protected string vcode;
    protected void Page_Load(object sender, EventArgs e)
    {
        //vcode = (string)Context.Session["vCode"];
    }

    protected void btnLogon_Click(object sender, ImageClickEventArgs e)
    {
        
        //string scode = this.code.Text;
        //this.code.Text = "";
        //if (scode != vcode)
        //{
        //    //ClientScript.RegisterStartupScript(this.GetType(), "incorrect", "<script language='javascript'>alert('验证码不正确.')</script>");
        //    ////ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('验证码不正确！')", true);
         
        //    return;
        //}
        OgilvyOne.BLL.LoginBll login = new OgilvyOne.BLL.LoginBll();
        if (login.login(userName.Text, MD5.GetMD5(password.Text), Context.Session))
        {
            if (!login.isDynamicPopedom(Session))
            {
                Hashtable map = (Hashtable)Session[OgilvyOne.BLL.LoginBll.LOGIN_USER_POPEDOM_KEY];
                if (map == null)
                {
                    Response.Redirect("infomation/managerFrame.aspx", true);
                    return;
                }

                if (map.ContainsKey("002"))
                {
                    Response.Redirect("infomation/managerFrame.aspx", true);
                }
                else if (map.ContainsKey("001"))
                {
                    Response.Redirect("column/managerFrame.aspx", true);
                }
                else if (map.ContainsKey("003"))
                {
                    Response.Redirect("manager/managerFrame.aspx", true);
                }
            }
            else
            {
                Response.Redirect("infomation/managerFrame.aspx", true);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "incorrect", "<script language='javascript'>alert('用户名或密码不正确.')</script>");
            return;
        }
    }   
}
